all files / raisedButton/ raisedButton.vue

50% Statements 9/18
57.14% Branches 4/7
11.11% Functions 1/9
30.77% Lines 4/13
1 branch Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125                            1× 1× 1×                                                                                                                                                                                                                        
//
//
//
//
//
//
//
//
//
//
//
//
//
 
import abstractButton from '../internal/abstractButton'
import {getColor} from '../utils'
import icon from '../icon'
export default {
  name: 'mu-raised-button',
  props: {
    label: {
      type: String
    },
    icon: {
      type: String
    },
    labelPosition: {
      type: String,
      default: 'after'
    },
    labelClass: {
      type: String,
      default: ''
    },
    primary: {
      type: Boolean,
      default: false
    },
    secondary: {
      type: Boolean,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    },
    keyboardFocused: {
      type: Boolean,
      default: false
    },
    fullWidth: {
      type: Boolean,
      default: false
    },
    href: {
      type: String,
      default: ''
    },
    target: {
      type: String
    },
    backgroundColor: {
      type: String,
      default: ''
    },
    color: {
      type: String,
      default: ''
    },
    rippleColor: {
      type: String
    },
    rippleOpacity: {
      type: Number
    }
  },
  data () {
    return {
      focus: false
    }
  },
  computed: {
    buttonStyle () {
      return {
        'background-color': getColor(this.backgroundColor),
        'color': getColor(this.color)
      }
    },
    inverse () {
      return this.primary || this.secondary || this.backgroundColor
    },
    buttonClass () {
      return {
        'mu-raised-button-primary': this.primary,
        'mu-raised-button-secondary': this.secondary,
        'label-before': this.labelPosition === 'before',
        'mu-raised-button-inverse': this.inverse,
        'mu-raised-button-full': this.fullWidth,
        'focus': this.focus,
        'no-label': !this.label
      }
    }
  },
  methods: {
    handleClick (e) {
      this.$emit('click', e)
    },
    handleKeyboardFocus (isFocus) {
      this.focus = isFocus
      this.$emit('keyboardFocus', isFocus)
    },
    handleHover (e) {
      this.$emit('hover', e)
    },
    handleHoverExit (e) {
      this.$emit('hoverExit', e)
    }
  },
  components: {
    'abstract-button': abstractButton,
    icon
  }
}